<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>15_ng-class&ng-class-even&ng-class-odd</title>
    <script src="../lib/angularjs.js"></script>
    <style>
        div {
            width: 500px;
            height: 100px;
            border: 1px solid black;
        }

        .box1 {
            background-color: pink;
            color: red;
        }

        .box2 {
            background-color: green;
            color: blueviolet;
        }

        table {
            width: 500px;
            border: 1px solid black;
        }

        th,
        td {
            text-align: left;
            border: 1px solid black;
        }
    </style>
</head>

<body ng-app="myApp" ng-controller="myCtrl">
    <label for="green">
        <input id="green" name="color" type="radio" ng-model="status" ng-value={{true}}>
        绿色背景
    </label>
    <label for="pink">
        <input id="pink" name="color" type="radio" ng-model="status" ng-value={{false}}>
        粉色背景
    </label>
    <div ng-class="{ box1: status, box2: !status }">{{status}}</div>
    <table>
        <tr>
            <th>编号</th>
            <th>名字</th>
            <th>内容</th>
        </tr>
        <tr ng-repeat="v in data" ng-class-even="'box1'" ng-class-odd="'box2'">
            <td>{{v.id}}</td>
            <td>{{v.name}}</td>
            <td>{{v.like}}</td>
        </tr>
    </table>
</body>

<script>
    const myApp = angular.module("myApp", [])
    myApp.controller("myCtrl", ["$scope", function ($scope) {
        $scope.status = true
        $scope.data = [{ id: 1, name: "小明", like: "街舞" }, { id: 2, name: "小花", like: "动漫" }, { id: 1, name: "小豪", like: "学习" }]
    }])
</script>

</html>